﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class InvTransferService : IInvTransferService
    {
        public string AutoRevertAllocate(string transferID, string updatedBy, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new OwnerTransferBLL(pubParasInfo).AutoRevertAllocate(transferID, updatedBy);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public string DeteleOwnerTransferDetailInfo(List<string> transferIDs, List<string> lineIDs, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new OwnerTransferDetailBLL(pubParasInfo).DeleteOwnerTransferDetail(transferIDs, lineIDs);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_DeteleOwnerTransferDetailInfo", transferIDs, lineIDs, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strTemp;
        }

        public string DeteleOwnerTransferInfo(List<string> transferIDs, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new OwnerTransferBLL(pubParasInfo).DeleteOwnerTransferInfo(transferIDs);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_DeteleOwnerTransferDetailInfo", transferIDs, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strTemp;
        }

        public string ExecuteInvOwnerTransfer(string transferID, string updatedBy, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new OwnerTransferBLL(pubParasInfo).ExecuteInvOwnerTransfer(transferID, updatedBy);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public DataSet GetInvOwnerTransferInfoByQueryEntity(OwnerTransferQueryEntity transferQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                OwnerTransferBLL transferBll = new OwnerTransferBLL(pubParasInfo);
                return transferBll.GetInvOwnerTransferInfoByQueryEntity(transferQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public OwnerTransferDetailInfo GetOwnerTransferDetailInfo(string transferID, string LineID, PubParasInfo pubParasInfo)
        {
            try
            {
                OwnerTransferDetailBLL OwnerTransferDetailBll = new OwnerTransferDetailBLL(pubParasInfo);
                return OwnerTransferDetailBll.GetOwnerTransferDetailInfoByID(transferID, LineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public OwnerTransferInfo GetOwnerTransferInfoByID(string transferID, PubParasInfo pubParasInfo)
        {
            try
            {
                OwnerTransferBLL transferBll = new OwnerTransferBLL(pubParasInfo);
                return transferBll.GetOwnerTransferInfoByID(transferID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public string InsertOwnerTransferDetailInfo(OwnerTransferDetailInfo transferDetailInfo, PubParasInfo pubParasInfo)
        {
            string transferDetailID = string.Empty;
            try
            {
                OwnerTransferDetailBLL transferDetailBll = new OwnerTransferDetailBLL(pubParasInfo);
                return transferDetailBll.InsertOwnerTransferDetailInfo(transferDetailInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return transferDetailID;
        }

        public string InsertOwnerTransferInfo(OwnerTransferInfo transferInfo, PubParasInfo pubParasInfo)
        {
            string transferID = string.Empty;
            try
            {
                transferID = new OwnerTransferBLL(pubParasInfo).InsertOwnerTransferInfo(transferInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_InsertOwnerTransferInfo", transferInfo, pubParasInfo);
                return transferID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return transferID;
        }

        public string TransferAllocate(string transferID, string updatedBy, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new OwnerTransferBLL(pubParasInfo).TransferAllocate(transferID, updatedBy);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public string UpdateOwnerTransferDetailInfo(OwnerTransferDetailInfo transferDetailInfo, PubParasInfo pubParasInfo)
        {
            string strOwnerTransferDetailID = string.Empty;
            try
            {
                strOwnerTransferDetailID = new OwnerTransferDetailBLL(pubParasInfo).UpdateOwnerTransferDatail(transferDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_UpdateOwnerTransferDetailInfo", transferDetailInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strOwnerTransferDetailID;
        }
    }
}

